<?php

namespace app\index\controller;

use app\common\controller\Frontend;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        return $this->view->fetch();
    }

    public function test()
    {
        $params = [
            'user_id' => 1,
            'claim_code' => '123456',
        ];
        $params_str = '';
        foreach ($params as $key => $value) {
            $params_str .= $key . '=' . $value . "&";
        }
//        $params_str = implode('&',$params);

        $file_dir = 'uploads/claimcode/' . date('Ym') . '/' . date('d') .'/';
        create($file_dir);
        $filename =  '/' . $file_dir . implode('',$params) . '.png';
        $file_path = ROOT_PATH . '/public/' . $filename;

        \PHPQRCode\QRcode::png($params_str, $file_path, 'L', 4, 2);
        echo "<img src='$filename'>";
    }

}
